package cobersky.skinUI.components
{
	import cobersky.skinUI.core.Component;
	import cobersky.skinUI.skins.core.IScrollerBarSkin;
	
	import flash.events.Event;
	import flash.events.MouseEvent;

	public class ScrollerBarBase extends Component
	{
		protected var _plusButton:Button;
		protected var _subButton:Button;
		protected var _bar:BarBase;
		private var _step:Number=0.1;
		private var _maxControl:Number;
		public function ScrollerBarBase() 
		{
		}
		
		override protected function setEnable():void
		{
			super.setEnable();
			_plusButton.enable=_subButton.enable=_bar.enable=true;
		}
		
		override protected function setUnable():void
		{
			trace("false");
			super.setUnable();
			_plusButton.enable=_subButton.enable=_bar.enable=false;
		}
		override public function attachSkin():void{
			super.attachSkin();
			var skin:IScrollerBarSkin=new _skinClass();
			_plusButton=skin.plusButton;
			_bar=skin.bar;
			_subButton=skin.subButton;
			_subButton.multiDispatch=true;
			_plusButton.multiDispatch=true;
			addChild(_bar);
			addChild(_subButton);
			addChild(_plusButton);
			_subButton.addEventListener(MouseEvent.MOUSE_DOWN,valueSub);
			_plusButton.addEventListener(MouseEvent.MOUSE_DOWN,valuePlus);
			_bar.addEventListener(Event.CHANGE,function(e:Event):void{dispatchEvent(e)});
		}
		protected function valueSub(event:MouseEvent):void{
			_bar.value-=_step;
		}
		protected function valuePlus(event:MouseEvent):void{
			_bar.value+=_step;
		}
		public function get value():Number{
			return _bar.value;
		}
		public function set value(v:Number):void{
			this._bar.value=v;
		}
	}
}